<?php
/*
Template Name: Custom
*/
?>

<?php get_header(); ?>

<?php get_template_part('flashing-home'); ?>

<div id="innerContainer" class="span-2">
<div id="sidebar">
<?php 
// use wp_list_pages to display parent and all child pages all generations (a tree with parent)
$args=array(
	'meta_key' => 'homepage-content',
	'meta_value' => 'left sidebar',
	'hierarchical' => 0,
);

$pages = get_pages($args);  
  
  foreach ($pages as $page) {
    $pageid = $page->ID;
	$title = $page->post_title;
	$content = $page->post_content;
	$link = get_page_link($pageid); 
	$class = get_post_meta($pageid, 'order', true); 
	 ?>
    <ul>
	<li class="<?php echo $class ?>"><h3><a href="<?php echo $link ?>"><?php echo $title ?></a></h3>
	<p><?php echo $content ?></p>
	</li>
	</ul>
<?php } ?>


</div><!-- sidebar -->
<div id="mainContent"> 

<div id="homeContent"> 
		<ul>
		<?php query_posts('category_name=homepage content'); ?>
		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
		<li>
			<h3><a href="<?php echo get_post_meta($post->ID, 'link', true) ?>"><?php the_title(); ?></a></h3>
			<?php the_content(); ?><a class="postLink" href="<?php echo get_post_meta($post->ID, 'link', true) ?>"><?php echo get_post_meta($post->ID, 'read-on-link', true) ?> &raquo;</a>
		</li>
		<?php endwhile; endif; ?>
		</ul>
</div><!-- homeContent -->

</div><!-- mainContent -->
</div><!-- innerContainer -->	
<?php get_sidebar(home); ?>
<div class="clear"></div>
<?php get_footer(); ?>